home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib2to3 / fixes / fix_ne.py < prev    next >
Encoding:
Python Source  |  2009-04-18  |  590 b   |  23 lines

  1. # Copyright 2006 Google, Inc. All Rights Reserved.
  2. # Licensed to PSF under a Contributor Agreement.
  3.  
  4. """Fixer that turns <> into !=."""
  5.  
  6. # Local imports
  7. from .. import pytree
  8. from ..pgen2 import token
  9. from .. import fixer_base
  10.  
  11.  
  12. class FixNe(fixer_base.BaseFix):
  13.     # This is so simple that we don't need the pattern compiler.
  14.  
  15.     def match(self, node):
  16.         # Override
  17.         return node.type == token.NOTEQUAL and node.value == "<>"
  18.  
  19.     def transform(self, node, results):
  20.         new = pytree.Leaf(token.NOTEQUAL, "!=")
  21.         new.set_prefix(node.get_prefix())
  22.         return new
  23.